package com.qlzb.taskmanagement.service;


import com.qlzb.taskmanagement.persistentData.dao.TowerBaseStationDao;
import com.qlzb.taskmanagement.persistentData.dao.TowerSysAreaDao;
import com.qlzb.taskmanagement.persistentData.entity.tower.TowerSysArea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TowerSysAreaService {
    @Autowired
    TowerSysAreaDao towerSysAreaDao;
    @Autowired
    TowerBaseStationDao towerBaseStationDao;
    //获取区域id
    public String gettownId(String cityName,String areaName){
        cityName = cityName.replace("分公司", "");
        cityName=cityName.replace("市", "")+"市";
        String seqCn=cityName+"-"+areaName;
        System.out.println("通过区域层级查找 区域"+seqCn);
        TowerSysArea town = this.towerSysAreaDao.findBySeqCnLikeAndDelFlag("%"+seqCn, 0);
        if (town != null) {
            System.out.println("已找到区域编码"+town.getId());
            return town.getId();
        }
        return null;
    }
    public String getCityId(String cityName)
    {
        String destr = cityName.replace("分公司", "");
        destr=destr.replace("市", "")+"市";
        TowerSysArea town = this.towerSysAreaDao.findByNameAndDelFlag(destr, 0);
        if (town != null) {
            return town.getId();
        }
        return null;
    }

    public List<TowerSysArea> findByParentId(String paramString){
        return this.towerSysAreaDao.findByParentId(paramString);
    }
}
